package jmu.cze.service.impl;

import javafx.scene.chart.Axis;
import jmu.cze.mapper.CabinMapper;
import jmu.cze.mapper.OnFlightMapper;
import jmu.cze.mapper.TerminalMapper;
import jmu.cze.mapper.TicketTypeMapper;
import jmu.cze.pojo.Cabin;
import jmu.cze.pojo.OnFlight;
import jmu.cze.pojo.TicketType;
import jmu.cze.service.OnFlightService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class OnFlightServiceImpl implements OnFlightService {
    private OnFlightMapper onFlightMapper;
    private CabinMapper cabinMapper;
    private TicketTypeMapper ticketTypeMapper;

    @Resource(name = "onFlightMapper")
    public void setOnFlightMapper(OnFlightMapper onFlightMapper) {
        this.onFlightMapper = onFlightMapper;
    }

    @Resource(name = "cabinMapper")
    public void setCabinMapper(CabinMapper cabinMapper) {
        this.cabinMapper = cabinMapper;
    }

    @Resource(name = "ticketTypeMapper")
    public void setTicketTypeMapper(TicketTypeMapper ticketTypeMapper) {
        this.ticketTypeMapper = ticketTypeMapper;
    }

    @Override
    public boolean deleteOnFlightByID(int onFlightID) {
        return onFlightMapper.deleteByID(onFlightID) == 1;
    }

    @Override
    public boolean insertOnFlight(OnFlight onFlight) {
        System.out.println(onFlight);
        return onFlightMapper.insert(onFlight) == 1;
    }

    @Override
    public List<OnFlight> selectOnFlightByFlightID(int flightID) {
        return onFlightMapper.selectByFlightID(flightID);
    }

    @Override
    public boolean updateOnFlight(OnFlight onFlight) {
        return onFlightMapper.update(onFlight) == 1;
    }

    @Override
    public boolean deleteCabinByID(int cabinID) {
        return cabinMapper.deleteByID(cabinID) == 1;
    }

    @Override
    public boolean insertCabin(Cabin cabin) {
        return cabinMapper.insert(cabin) == 1;
    }

    @Override
    public Map<Integer, Cabin> selectAllCabins() {
        return cabinMapper.selectAllCabins();
    }

    @Override
    public boolean updateCabin(Cabin cabin) {
        return cabinMapper.update(cabin) == 1;
    }

    @Override
    public boolean deleteTicketTypeByID(Integer ticketTypeID) {
        return ticketTypeMapper.deleteByID(ticketTypeID) == 1;
    }

    @Override
    public boolean insertTicketType(TicketType ticketType) {
        return ticketTypeMapper.insert(ticketType) == 1;
    }

    @Override
    public TicketType selectTicketTypeByID(Integer ticketTypeID) {
        return ticketTypeMapper.selectByID(ticketTypeID);
    }

    @Override
    public List<TicketType> selectTicketTypeByOnFlightID(Integer onFlightID) {
        return ticketTypeMapper.selectByOnFlightID(onFlightID);
    }

    @Override
    public boolean updateTicketType(TicketType ticketType) {
        return ticketTypeMapper.update(ticketType) == 1;
    }
}
